/*
 * @Autor        : LiJia
 * @Date         : 2021-12-19 02:40:04
 * @LastEditTime : 2021-12-19 04:39:07
 * @FilePath     : \src\plugins\api-request.ts
 * @Description  : 请求方法
 */
import axios from 'axios'

const headers = {
  Accept: 'application/json',
  'Access-Control-Allow-Origin': '*',
  'Content-Type': 'application/json;chatset=utf-8',
  'x-auth-token': 'null',
}

// 不带拦截器的请求
const apiRequest = (request: any) => {
  request['headers'] = headers
  debugger
  return new Promise((resolve, reject) => {
    axios(request).then((response) => {
      resolve(response)
    }).catch((error) => {
      reject(error)
    })
  })
}


const install = (app: any) => {
  app.config.globalProperties.$request = apiRequest
}

export default { apiRequest, install }
